package com.yyge.util;

import javax.xml.crypto.Data;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;

/**
 * @program: js-hd
 * @description: 时间工具类
 * @author: yyf
 * @create: 2024-02-02 09:01
 **/


public class DateUtil {
    public static Date format(String str,Integer type){
        String mat="yyyy-MM-dd HH:mm:ss"; //默认转换规则
        Date date = new Date();
        if (type.equals(1)){
          mat="yyyy-MM-dd";
        }
        SimpleDateFormat sdf = new SimpleDateFormat(mat);
        try {
            date = sdf.parse(str);
            System.out.println(date);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return date;
    }
}
